home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / muds / lpmud312.tar / lpmud312 / interpret.h < prev    next >
C/C++ Source or Header  |  1992-01-11  |  2KB  |  69 lines

  1. union u {
  2.     char *string;
  3.     int number;
  4.     struct object *ob;
  5.     struct vector *vec;
  6.     struct svalue *lvalue;
  7. };
  8.  
  9. /*
  10.  * The value stack element.
  11.  * If it is a string, then the way that the string has been allocated differ,
  12.  * wich will affect how it should be freed.
  13.  */
  14. struct svalue {
  15.     short type;
  16.     short string_type;
  17.     union u u;
  18. };
  19.  
  20. #define T_INVALID    0x0
  21. #define T_LVALUE    0x1
  22. #define T_NUMBER    0x2
  23. #define T_STRING    0x4
  24. #define T_POINTER    0x8
  25. #define T_OBJECT    0x10
  26.  
  27. #define STRING_MALLOC    0    /* Allocated by malloc() */
  28. #define STRING_CONSTANT    1    /* Do not has to be freed at all */
  29. #define STRING_SHARED    2    /* Allocated by the shared string library */
  30.  
  31. struct vector {
  32.     short size;
  33.     short ref;
  34. #ifdef DEBUG
  35.     int extra_ref;
  36. #endif
  37.     struct wiz_list *user;    /* Save who made the vector */
  38.     struct svalue item[1];
  39. };
  40.  
  41. #define ALLOC_VECTOR(nelem) \
  42.     (struct vector *)xalloc(sizeof (struct vector) + \
  43.                 sizeof(struct svalue) * (nelem - 1))
  44.  
  45. struct lnode_def;
  46. void free_vector PROT((struct vector *)), free_all_values();
  47.  
  48. /*
  49.  * Control stack element.
  50.  * 'prog' is usually same as 'ob->prog' (current_object), except when
  51.  * when the current function is defined by inheritance.
  52.  * The pointer, csp, will point to the values that will be used at return.
  53.  */
  54. struct control_stack {
  55.     struct object *ob;        /* Current object */
  56.     struct object *prev_ob;    /* Save previous object */
  57.     struct program *prog;    /* Current program */
  58.     int num_local_variables;    /* Local + arguments */
  59.     char *pc;
  60.     struct svalue *fp;
  61.     int extern_call;        /* Flag if evaluator should return */
  62.     struct function *funp;    /* Only used for tracebacks */
  63.     int function_index_offset;    /* Used when executing functions in inherited
  64.                    programs */
  65.     int variable_index_offset;    /* Same */
  66.     short *break_sp;
  67. };
  68.  
  69.